package com.cykj.faceledtv.data.pref;


import android.content.Context;
import android.content.SharedPreferences;

import com.cykj.faceledtv.di.ApplicationContext;
import com.cykj.faceledtv.di.PreferenceInfo;

import javax.inject.Inject;
import javax.inject.Singleton;

/**
 * pref具体实现
 *
 * @author jzh
 * @date 2018/12/11 18:17
 */
@Singleton
public class AppPreferencesHelper implements PreferencesHelper {
    private final SharedPreferences mPrefs;
    private final String LOGIN_ID = "loginId";
    private final String LOGIN_PWD = "loginPwd";

    @Inject
    public AppPreferencesHelper(@ApplicationContext Context context,
                                @PreferenceInfo String prefFileName) {
        mPrefs = context.getSharedPreferences(prefFileName, Context.MODE_PRIVATE);
    }

    @Override
    public void setLoginId(String loginId) {
        mPrefs.edit().putString(LOGIN_ID, loginId).apply();
    }

    @Override
    public String getLoginId() {
        return mPrefs.getString(LOGIN_ID, "0000000000");
    }

    @Override
    public void setLoginPassword(String password) {
        mPrefs.edit().putString(LOGIN_PWD, password).apply();
    }

    @Override
    public String getLoginPassword() {
        return mPrefs.getString(LOGIN_PWD, "FFFFFFFFFF");
    }

    @Override
    public void setInOutAdv(String adv) {
        mPrefs.edit().putString("inOutAdv", adv).apply();
    }

    @Override
    public String getInOutAdv() {
        return mPrefs.getString("inOutAdv", "");
    }

    @Override
    public void setFreeAdv(String adv) {
        mPrefs.edit().putString("freeAdv", adv).apply();
    }

    @Override
    public String getFreeAdv() {
        return mPrefs.getString("freeAdv", "");
    }

    @Override
    public void setAddress(String address) {
        mPrefs.edit().putString("address", address).apply();
    }

    @Override
    public String getAddress() {
        return mPrefs.getString("address", "深圳市");
    }

    @Override
    public void setSiteName(String siteName) {
        mPrefs.edit().putString("siteName", siteName).apply();
    }

    @Override
    public String getSiteName() {
        return mPrefs.getString("siteName", "");
    }
}
